/**
 * 将对象数据存储到localStorage
 */
export const setObj = (key: string, value: any) => {
  localStorage.setItem(key, JSON.stringify(value));
};

/**
 * 从localStorage获取对象数据
 */
export const getObj = (key: string) => {
  const data = localStorage.getItem(key);
  if (data) {
    return JSON.parse(data);
  }
  return null;
};
/**
 * 清除localStorage指定数据
 */
export const clearKey = (key: string) => {
  localStorage.removeItem(key);
};

/**
 * 将字符串数据存储到localStorage
 */
export const setStr = (key: string, value: string) => {
  localStorage.setItem(key, value);
};
/**
 * 从localStorage获取字符串数据
 */
export const getStr = (key: string) => {
  return localStorage.getItem(key);
};

/**
 * 清除localStorage
 */
export const clearLocalStorage = () => {
  localStorage.clear();
};

